<template>


	<view class="flex-col section_5">
		<view class="flex-row items-center input" @click="batinput">
			<image class="image_6" src="/static/icon/dingwei.png" />

			<input class="fontsizetit" style="margin-left:18rpx;font-size:28rpx;color:#000;width:550rpx;"
				placeholder-style=" font-size:28rpx; font-family: PingFang SC; line-height: 30rpx; color: #999999;"
				v-model="onew.position.name" placeholder="您的详细地址" type="text" />
		</view>
		<view class="flex-col group_6">
			<view class="flex-col group_7">
				<view class="flex-row items-center input_2" @click="quotation">
					<image class="image_7" src="/static/icon/shizhong.png" />

					<input class="fontsizetit" disabled style="margin-left:18rpx;font-size:28rpx;color:#000;width: 550rpx; "
						placeholder-style=" font-size:28rpx; font-family: PingFang SC; line-height: 30rpx; color: #999999;"
						placeholder="选择上门时间" v-model="moving_time_str" type="text" />
				</view>
				<view class="mt-16 flex-row items-center input_3">
					<image class="image_8" src="/static/icon/lxr.png" />

					<input class="fontsizetit" style="margin-left:18rpx;font-size:28rpx;color:#000;width: 100%;"
						placeholder-style=" font-size:28rpx; font-family: PingFang SC; line-height: 30rpx; color: #999999;" maxlength="10"
						v-model="name" placeholder="请输入联系人" type="text" @blur="handleBlur" />

				</view>
				<view class="mt-16 flex-row items-center section_6">
					<image class="image_9" src="/static/icon/shss44.png" />

					<input class="fontsizetit" style="margin-left:18rpx;font-size:28rpx;color:#000;width:100%;" maxlength="11"
						v-model="phone" @blur="handleBlur"
						placeholder-style="font-size:28rpx; font-family: PingFang SC; line-height: 30rpx; color: #999999;"
						placeholder="输入联系电话" type="number" />



				</view>
			</view>
			<!-- 		    <view class=" flex-col justify-start items-center button"><text class="text_15"  @click="quotation"  >定制报价方案</text></view> -->
		</view>


		<my-timing ref="timeinRefs" @loginSucce="updateUserInfo"></my-timing>
	</view>



</template>

<script>
	import TiMing from '@/components/Timing.vue'; // 导入 选择时间 组件
	export default {
		name: "Storage",
		components: {
			'my-timing': TiMing, // 注册 时间 组件

		},
		data() {
			return {
				  onew: {
				      position: {
				        name: ''
				      }
				    },

				// onew: {},
				time: {},

				moving_time_str: '',
				name: "",
				phone: '',


			};
		},


		methods: {



			tabse() {

				uni.navigateTo({
					url: '/pages/address/address?type=' + 3 + '&initm=' + 1
				})
			},

			// 更新页面数据
			uentestay() {

				const myData = uni.getStorageSync('qwzlsn');
    
				if (myData.onew) {
					this.onew = JSON.parse(myData.onew) || '';

				}
    

				if (myData != "") {
					// this.onew = myData.onew || '';
					this.time = myData.time || '';
					this.moving_time_str = myData.time.moving_time_str || '';
					this.name = myData.name || '';
					this.phone = myData.phone || '';

				}
				
				this.$forceUpdate()

			},
			updateData(e) {


			},

			handleBlur() {

				// 全屋收纳整理缓存到本地里
				var pho = this.phone

				if (this.phone.length == 11) {

					const phoneNumber = this.phone;
					const regex = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
					if (regex.test(phoneNumber)) {
						console.log("手机号码格式正确,请求验证码");

					} else {
						console.log("手机号码格式不正确");
						uni.showToast({
							title: '手机号码有误',
							icon: 'none',
							duration: 2000
						})
					}

				}

				var key = 'qwzlsn'

				// uni.setStorageSync('LoginData', res.data.data);
				// const myData = uni.getStorageSync('LoginData');
				var data = uni.getStorageSync(key) || {}; // 获取存储的数据或者创建一个新的对象


				data.address = this.address,
					data.time = this.time,
					data.name = this.name,
					data.phone = this.phone
				uni.setStorageSync(key, data); // 将更新后的对象存储回去
			},

			// 更新的时间
			updateUserInfo(time) {


				console.log(time, 66666)
				this.moving_time_str = time.moving_time_str;
				this.time = time;

				// 更新页面数据到本地
				this.handleBlur()
			},





			// 选择地址
			batinput() {
				// uni.navigateTo({
				// 	url:'/pages/address/address'
				// })

				uni.navigateTo({
					url: '/pages/address/address?type=' + 3 + '&initm=' + 1
				})

				return

				var _this = this
				wx.chooseLocation({
					success: function(res) {

						// 用户成功选择位置后的回调函数
						_this.address = res

						//    console.log(res.name);        // 位置名称
						//    console.log(res.address);     // 详细地址
						//    console.log(res.latitude);    // 纬度
						//    console.log(res.longitude);   // 经度
						_this.handleBlur()
					},
					fail: function(err) {
						// 用户取消选择或发生错误时的回调函数
						console.error(err);
					},
					complete: function() {
						// 不论成功或失败，选择操作结束时的回调函数
					}
				})


			},
			// 定制报价
			quotation() {

				// 通过 $refs 获取子组件实例
				const loginComponent = this.$refs.timeinRefs;

				// 调用子组件方法
				loginComponent.open(2);



			}
		},
	}
</script>

<style lang="less" scoped>
	.ml-7-5 {
		margin-left: 15rpx;
	}

	.ml-9-5 {
		margin-left: 19rpx;
	}

	.ml-8-5 {
		margin-left: 17rpx;
	}

	.ml-10-5 {
		margin-left: 21rpx;
	}

	.section_5 {
		padding: 0 10rpx;
		background-color: #ffffff;
		border-radius: 0rpx 16rpx 16rpx 16rpx;

		.group_5 {
			padding: 34rpx 114rpx 46rpx 132rpx;

			.font_4 {
				font-size: 28rpx;
				font-family: PingFang SC;
				line-height: 22.32rpx;
				color: #666666;
			}

			.text_9 {
				line-height: 21.9rpx;
			}

			.text_10 {
				line-height: 22.12rpx;
			}

			.text_11 {
				color: #2b8eff;
				line-height: 22.52rpx;
			}
		}

		.input {
			padding: 30rpx 20rpx;
			background-color: #f4f5f7;
			border-radius: 8rpx;

			.image_6 {
				width: 36rpx;
				height: 36rpx;
			}

			.text_12 {
				line-height: 22.1rpx;
			}
		}

		.font_3 {
			font-size: 28rpx;
			font-family: PingFang SC;
			line-height: 22.32rpx;
			color: #999999;
		}

		.group_6 {
			padding-bottom: 40rpx;

			.group_7 {
				padding: 32rpx 0 48rpx;

				.input_2 {
					padding: 30rpx 24rpx;
					background-color: #f4f5f7;
					border-radius: 8rpx;

					.image_7 {
						width: 28rpx;
						height: 28rpx;
					}
				}

				.input_3 {
					padding: 30rpx 22rpx;
					background-color: #f4f5f7;
					border-radius: 8rpx;

					.image_8 {
						border-radius: 98rpx;
						width: 32rpx;
						height: 32rpx;
					}

					.text_13 {
						line-height: 22.2rpx;
					}
				}

				.section_6 {
					padding: 30rpx 26rpx;
					background-color: #f4f5f7;
					border-radius: 8rpx;

					.image_9 {
						border-radius: 4rpx;
						width: 24rpx;
						height: 32rpx;

					}

					.text_14 {
						line-height: 23.64rpx;
					}
				}
			}

			.button {
				padding: 28rpx 0;
				background-color: #2b8eff;
				border-radius: 8rpx;

				.text_15 {
					color: #ffffff;
					font-size: 36rpx;
					font-family: PingFang SC;
					line-height: 33.72rpx;
				}
			}
		}
	}
</style>